package com.example.demo.controller;

import com.example.demo.config.State;
import com.example.demo.entity.ResponseJson;
import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public ResponseJson login(User user) {
        if (user.getAccount() == null || user.getPwd() == null) {
        return new ResponseJson(State.FAIL,"用户名密码不能为空");
        }
        return userService.login(user.getAccount(),user.getPwd());
    }

}
